import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';

@Component({
  selector: 'app-extract-template',
  templateUrl: './extract-template.component.html',
  styleUrls: ['./extract-template.component.scss']
})
export class ExtractTemplateComponent implements OnInit {

  public isNone:boolean = true;
  public isTips:boolean = true;
  public keyList:any[]=[{id:1,val:''},{id:2,val:''},{id:3,val:''}];
  public showIconIndex = -1;
  public showEditIndex = -1;

  constructor(private router: Router) { }

  ngOnInit() {
  }

  uploadImg(){
    this.isNone = false;
  }
  //修改
  changeKey(key:any,val:any){
    // this.keyList[key] = val.target.value;
  }
  //删除
  deleteKey(item:any){
    const index = this.keyList.indexOf(item);
    this.keyList.splice(index,1);
  }
  //新增
  addKey(){
    const id = this.keyList.length > 0 ? this.keyList[this.keyList.length - 1].id + 1 : 0;
    const control = {
      id,
      val: ''
    };
    this.keyList.push(control);
  }
  nextStep(){
    this.router.navigate(['/extract/extractDataset']);
  }
  closeTips(){
    this.isTips = false;
  }
  showIcon(key){
    this.showIconIndex = key;
  }
  edit(key){
    this.showEditIndex = key;
  }
  disableTxt(index){
    if(index == this.showEditIndex)
      this.showEditIndex = -1;
  }
}
